describe "PickProductCtrl", ->
    $scope = $state = $controller = $httpBackend = $ionicHistory = $ionicViewSwitcher = undefined

    beforeEach ->
        angular.module('constants', [])
          .constant 'cdn', 'xxx'
        module 'ionic'
        module 'utils'
        module 'wf-config'
        module 'wf-log'
        module 'data-srv'
        module 'pick-product'
        module 'constants'


    beforeEach inject ($injector) ->
        $state             = $injector.get '$state'
        $rootScope         = $injector.get('$rootScope')
        $controller        = $injector.get('$controller')
        $ionicHistory      = $injector.get '$ionicHistory'
        $ionicViewSwitcher = $injector.get '$ionicViewSwitcher'
        #$httpBackend = $injector.get('$httpBackend')

        #spyOn($location , 'path')
        #spyOn($notify   , 'wait')
        #spyOn(userData  , 'get').andCallFake -> user

        $scope = $rootScope.$new()
        $controller("PickProductCtrl", {$scope: $scope})

    it 'should go special', ->
        spyOn $state, 'go'
        $scope.goSpecial()
        expect( $state.go ).toHaveBeenCalledWith 'tab.special-require'

    it 'should go back', ->
        spyOn($ionicHistory, 'goBack')
        spyOn($ionicViewSwitcher, 'nextDirection')
        $scope.goBack()
        expect($ionicHistory.goBack).toHaveBeenCalled()
        expect($ionicViewSwitcher.nextDirection).toHaveBeenCalledWith('back')

    it 'should decrease amount of product', ->
        data = amount: 2
        $scope.dec data, 0, []
        expect(data.amount).toEqual(1)
        $scope.dec data, 0, []
        $scope.dec data, 0, []
        expect(data.amount).toEqual(0)
